/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 */

#include <cstdio>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define EOL(i, n) " \n"[i == (n) - 1]

typedef long long ll;

const int maxn = 1 << 15;

ll init = 0, sum;
int n, m, val[maxn * 2], is[maxn * 2];
ll f[maxn * 2];

ll Get( int v, int vl, int vr, int l, int r )
{
  if (r < vl || vr < l)
    return 0;
  if (is[v])
    return (ll)val[v] * (min(vr, r) - max(vl, l) + 1);
  if (l <= vl && vr <= r)
    return f[v];
  int vm = (vl + vr) / 2;
  return Get(2 * v, vl, vm, l, r) + Get(2 * v + 1, vm + 1, vr, l, r);
}

void Set( int v, int vl, int vr, int l, int r, int newVal )
{
  if (r < vl || vr < l)
    return;
  if (l <= vl && vr <= r)
  {
    is[v] = 1, val[v] = newVal, f[v] = (ll)newVal * (vr - vl + 1);
    return;
  }
  if (is[v])
  {
    is[v] = 0;
    is[2 * v] = is[2 * v + 1] = 1;
    val[2 * v] = val[2 * v + 1] = val[v];
    f[2 * v] = f[2 * v + 1] = f[v] / 2;
  }
  int vm = (vl + vr) / 2;
  Set(2 * v, vl, vm, l, r, newVal);
  Set(2 * v + 1, vm + 1, vr, l, r, newVal);
  f[v] = f[2 * v] + f[2 * v + 1];
}

int main()
{
  #define NAME "middle"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  scanf("%d%d", &n, &m);
  forn(i, n)
  {
    int x;
    scanf("%d", &x), init += x;
    f[maxn + i] = x;
  }
  sum = init;
  fornd(i, maxn)
    f[i] = f[2 * i] + f[2 * i + 1];

  while (m--)
  {
    int a, b, len;
    scanf("%d%d", &a, &b), a--, b--;
    assert(0 <= a && a <= b && b < n);
    len = b - a + 1;

    ll cur = Get(1, 0, maxn - 1, a, b);
    int val = (int)floor((sum <= init ? (double)(cur + len - 1) / len : (double)cur / len) + 1e-6);
    sum += (ll)val * len - cur;

    Set(1, 0, maxn - 1, a, b, val);
  }
  forn(i, n)
    printf("%d%c", (int)Get(1, 0, maxn - 1, i, i), EOL(i, n));
  return 0;
}
